﻿@model AplicacionBase.Models.User
@{
    ViewBag.Title = "Editar";
}

<script type="text/javascript">
    $(document).ready(function () {
        $("#BirthDate").datepicker({ dateFormat: 'dd/mm/yy' });
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#BirthDate").change(function () {
            var now = new Date();
            var errorDate = false;
            var startDt = $("#BirthDate").val();
            var endDt = now.getDate() + "-" + now.getMonth() + "-" + now.getFullYear();
            var aI = startDt.substring(0, 4);
            var aF = endDt.substring(5, 10);
            if (aI == aF) {
                var mI = startDt.substring(5, 7);
                var mF = endDt.substring(3, 4);
                if (mI <= mF) {
                    var dI = startDt.substring(8, 10);
                    var dF = endDt.substring(0, 2);
                    if (dI > dF) {
                        errorDate = true;
                    }
                } else {
                    errorDate = true;
                }
            }
            else {
                if (aI > aF) {
                    errorDate = true;
                }
            }
            if (errorDate) {
                $('<p>').text('Su fecha  de cumpleaños no debe ser posterior a la fecha actual').appendTo('#ErrorBirthDate').hide(20000, function () { $(this).remove(); });

                $("#BirthDate").val("");
            }
        });
    });
</script>


<h2>
    Editar Información Personal</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Usuario: @Model.aspnet_Users.UserName</legend>
        <div>&nbsp</div>
        <p>Los campos marcados con (*) son obligatorios</p>
        @Html.HiddenFor(model => model.Id)
        <div class="editor-label"><h3>@Html.LabelFor(model => model.PhoneNumber)</h3> </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneNumber)
            @Html.ValidationMessageFor(model => model.PhoneNumber)
        </div>

        <div class="editor-label"><h3>@Html.LabelFor(model => model.FirstNames)</h3></div>
        
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstNames)
            @Html.ValidationMessageFor(model => model.FirstNames)
        </div>

        <div class="editor-label"><h3>@Html.LabelFor(model => model.LastNames)</h3></div>
       
        <div class="editor-field">
            @Html.EditorFor(model => model.LastNames)
            @Html.ValidationMessageFor(model => model.LastNames)
        </div>

        <div class="editor-label"><h3> @Html.LabelFor(model => model.Address)</h3></div>
        
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
        </div>

        <div class="editor-label"><h3> @Html.LabelFor(model => model.CellphoneNumber)</h3></div>
       
        <div class="editor-field">
            @Html.EditorFor(model => model.CellphoneNumber)
            @Html.ValidationMessageFor(model => model.CellphoneNumber)
        </div>

        <div class="editor-label"><h3>@Html.LabelFor(model => model.BirthDate)</h3></div>
        
        <div class="editor-field">
            @Html.EditorFor(model => model.BirthDate)
            @Html.ValidationMessageFor(model => model.BirthDate)
        </div>
        <div class="alert error" id = "ErrorBirthDate"></div>
        <div class="editor-label"><h3>@Html.LabelFor(model => model.Gender)</h3>
            <div>
                @Html.RadioButtonFor(model => model.Gender, "M")
                Masculino
            </div>
            <div>
                @Html.RadioButtonFor(model => model.Gender, "F")                
                Femenino
            </div>
        </div>

        <div class="editor-label"><h3> @Html.LabelFor(model => model.MaritalStatus)</h3></div>
        <div class="editor-field">
            <div>
                @Html.RadioButtonFor(model => model.MaritalStatus, "Soltero")
                Soltero 
            </div>
            <div>
                @Html.RadioButtonFor(model => model.MaritalStatus, "Casado")
                Casado 
            </div>
            <div>
                @Html.RadioButtonFor(model => model.MaritalStatus, "U Libre") 
                Unión Libre 
            </div>

            <div>&nbsp</div>
        </div>

        <div>
            <input type="submit" value="Guardar" class="ebutton blue" />&nbsp
            <input type="button" value="Atrás" onclick="history.go(-1)" class="ebutton blue" />
        </div>
    </fieldset>
}
